'use strict'

function getDataByKeyword(keyword) {
    return new Promise(function (resolve, reject) {
        $.get(`${url}/bolg?keyword=${keyword}`, (res) => {
            let tmp = res.data;

            resolve(tmp);
        })
    })
}

function getDataById(id) {
    return new Promise(function (resolve, reject) {
        $.get(`${url}/bolg/${id}`, (res) => {
            let tmp = res.data;
            resolve(tmp);
        })
    })
}


function addData(obj) {
    return new Promise(function (resolve, reject) {
        $.post(`${url}/bolg`, obj, (res) => {
            resolve();
        })
    })
}


function updateData(id, obj) {
    return new Promise(function (resolve, reject) {
        $.ajax({
            url: `${url}/bolg/${id}`,
            data: obj,
            type: 'PUT',
            success: function () {
                resolve();
            }
        })
    })
}


function deleteData(id) {
    return new Promise(function (resolve, reject) {
        $.ajax({
            url: `${url}/bolg/${id}`,
            type: 'DELETE',
            success: function (res) {
                let tmp = res.data;
                resolve(tmp);
            }
        })
    })
}